/**
 * Copyright (C) 2018-2022
 * All rights reserved, Designed By www.yixiang.co
 * 注意：
 * 本软件为www.yixiang.co开发研制
 */
package co.yixiang.modules.monitoring.entity.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import co.yixiang.common.domain.BaseDomain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.models.auth.In;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * @author hupeng
 * @date 2020-05-12
 */
@EqualsAndHashCode(callSuper = true)
@TableName("yx_monitoring_category")
@Data
@NoArgsConstructor
public class YxMonitoringCategory extends BaseDomain {

    /** 分类ID */
    @TableId
    private Integer id;

    /** 父ID */
    private Integer parentId;

    /** 排序 */
    @Min(value = 0,message = "排序值最小0，最大9999999999")
    @Max(value = 999999999,message = "排序值最小0，最大9999999999")
    @NotNull(message = "排序值不能为空")
    private Integer sort;

    /** 分类名 */
    @NotBlank(message = "请填写分类名称")
    private String name;


    public Integer getSort() {
        if (sort == null) {
            return 0;
        }
        return sort;
    }

    public void copy(YxMonitoringCategory source) {
        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
    }
}
